import java.util.Stack;
import java.util.ArrayList;
/**
 * @Author: Lenovo
 * @Date: 2024/7/17 20:08
 * @description:
 */
public class Test {
    public static void main(String[] args) {
        Stack<Integer> stack= new Stack();
        stack.push(1);
        stack.push(2);
        stack.push(3);
        stack.push(4);
        System.out.println(stack.size()); // 获取栈中有效元素个数---> 4
        System.out.println(stack.peek()); // 获取栈顶元素---> 4
        stack.pop(); // 4出栈，栈中剩余1 2 3，栈顶元素为3
        System.out.println(stack.pop()); // 3出栈，栈中剩余1 2 栈顶元素为3
        if(stack.empty()){
            System.out.println("栈空");
        }else{
            System.out.println(stack.size());
        }
    }
    public static void main1(String[] args) {
        MyStack stack = new MyStack();
        stack.push(1);
        stack.push(2);
        stack.push(3);
        stack.push(4);
        stack.push(5);
        int pop = stack.pop();
        System.out.println(pop);
        int peek = stack.peek();
        System.out.println(peek);
    }
}
